package com.me.modules.chg.service.impl;

import com.me.modules.common.common.Constant;
import com.me.modules.common.page.Page;
import com.me.modules.common.page.PageHelper;
import com.me.modules.common.utils.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.me.modules.chg.dao.ChangeInfoDao;
import com.me.modules.chg.entity.ChangeInfoEntity;
import com.me.modules.chg.service.ChangeInfoService;



@Service("changeInfoService")
public class ChangeInfoServiceImpl implements ChangeInfoService {
	@Autowired
	private ChangeInfoDao changeInfoDao;

	@Override
	public ChangeInfoEntity queryObject(Long id){
		return changeInfoDao.queryObject(id);
	}

	@Override
	public List<ChangeInfoEntity> queryList(Map<String, Object> map){
		return changeInfoDao.queryList(map);
	}

    @Override
    public List<ChangeInfoEntity> queryListByBean(ChangeInfoEntity entity) {
        return changeInfoDao.queryListByBean(entity);
    }

	@Override
	public int queryTotal(Map<String, Object> map){
		return changeInfoDao.queryTotal(map);
	}

	@Override
	public int save(ChangeInfoEntity changeInfo){
		changeInfo.setStatus("1");
		changeInfo.setStartTime(new Date());
		changeInfo.setReqId(UserUtils.getCurrentUserId());

		return changeInfoDao.save(changeInfo);
	}

	@Override
	public int update(ChangeInfoEntity changeInfo){
        return changeInfoDao.update(changeInfo);
	}

	@Override
	public int delete(Long id){
        return changeInfoDao.delete(id);
	}

	@Override
	public int deleteBatch(Long[] ids){
        return changeInfoDao.deleteBatch(ids);
	}

	@Override
	public Page<ChangeInfoEntity> findPage(ChangeInfoEntity changeInfo, int pageNum) {
		PageHelper.startPage(pageNum, Constant.pageSize);
		changeInfoDao.queryList(changeInfo);
		return PageHelper.endPage();
	}
}
